#ifndef __LIBIPRIV_H
#define __LIBIPRIV_H


#if defined(__cplusplus)
extern "C" {
#endif

// Thread-unsafe functions family (original version)
int CryptInit(void);
int Crypt_InitKeys(char* PubKey,char* SecKey,char* keystring,char* randseedpath);
int Crypt_CheckSign(char *Document,char *UserKey);
char* Crypt_Sign(char* Body);
char* Crypt_SignKey(char* Key);
int Crypt_Encrypt(char* Body,char* UserKey,char** Signature,char** CryptBody);
char* Crypt_Decrypt(char* Document);
int Crypt_InitKeyFiles(char* PubKeyFName,char* SecKeyFName,char* keystring,long UserKeySerial,
	long BankKeySerial,char* randseedpath);
int Crypt_CheckUserSign(char* Document);
int Crypt_CheckBankSign(char* Document);
int Crypt_BankEncrypt(char* Body,char** Signature,char** CryptBody);
int GetIPrivLastError(char* sBuffer,int nLength);
int CryptDone(void);

// Thread-unsafe wrap functions family (old version)
int Sign(char*,char*,char*,char*,int);
bool CheckSign(char*,char*,char*,int);


// Thread-safe wrap functions family (new version)

#ifdef _WIN32
#define	IPRIVAPI	__stdcall
#else
#define	IPRIVAPI
#endif

typedef void* IPRIVSECRETKEY;
typedef void* IPRIVPUBLICKEY;

int IPRIVAPI Crypt_Init(const char* randseedpath);
IPRIVSECRETKEY IPRIVAPI Crypt_LoadSecretKey(char *UserKey,char *keystring,char* errmsg,int nerrmsg);
IPRIVSECRETKEY IPRIVAPI Crypt_LoadSecretKeyFromFile(char *KeyFName,char *keystring,char* errmsg,int nerrmsg);
int IPRIVAPI Crypt_FreeSecretKey(IPRIVSECRETKEY key);
IPRIVPUBLICKEY IPRIVAPI Crypt_LoadPublicKey(char *UserKey,IPRIVPUBLICKEY userkey,char* errmsg,int nerrmsg);
IPRIVPUBLICKEY IPRIVAPI Crypt_LoadPublicKeyFromFile(char *KeyFName,IPRIVPUBLICKEY userkey,long KeySerial,
	char* errmsg,int nerrmsg);
int IPRIVAPI Crypt_FreePublicKey(IPRIVPUBLICKEY key);
char* IPRIVAPI Crypt_SignMessage(const char* msg,int nmsg,char* errmsg,int nerrmsg);
char* IPRIVAPI Crypt_SignMessageEx(const char* msg,int nmsg,IPRIVSECRETKEY key,char* errmsg,int nerrmsg);
char* IPRIVAPI Crypt_VerifyMessage(const char* msg,int nmsg,char* errmsg,int nerrmsg);
char* IPRIVAPI Crypt_VerifyMessageEx(const char* msg,int nmsg,IPRIVPUBLICKEY key,char* errmsg,int nerrmsg);
char* IPRIVAPI Crypt_DecryptEx(char *Document,IPRIVSECRETKEY userkey,IPRIVPUBLICKEY bankkey,
	char* errmsg,int nerrmsg);
void IPRIVAPI Crypt_FreeMessage(char* msg);
int IPRIVAPI Crypt_Done(void);


#if defined(__cplusplus)
}
#endif




#endif
